home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Communications / General / LineShare Folder / Put Onto Productions Disks / LineShare Scripts / Supra Voice&Fax1&ARA-old < prev    next >
Text File  |  1994-02-10  |  8KB  |  443 lines

  1. ! Version 2.1
  2. !
  3. !$ Use this script with Supra 14400bps and 9600bps fax modems.
  4. !$ Supports: voice, fax, and ARA incoming calls.
  5. !
  6. !$ Make sure that *Class 1* fax software is installed, and that
  7. !$ your modem has voice-capable ROMs.
  8. !
  9. !$ A hardware handshaking cable is required.
  10.  
  11. ^2 Speaker On:        = Enum("Never" = "0","During Connect" = "1", "Always"="2") "1"
  12. ^3 Speaker Volume:       = Enum("Low"="1","Medium"="2","High"="3") "2"
  13. ^4 Answer On:         = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  14. ^6 Handshake wires:   = Bool("Both"="&D0\K0","CTS only"="&D2\K5") "&D2\K5"
  15. ! ------------------------------------------
  16. ! Resetting the modem:
  17. ! ------------------------------------------
  18. @HANGUP
  19.   SetTries 2
  20.   Flush
  21.   HsReset 0,0,17,19,0,0
  22. !
  23. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  24. ! to enter the command mode
  25. !
  26. @Label 1
  27.   write "ATH0&F1\r"
  28.   matchclr
  29.   matchstr 1 2 "OK\r\n"
  30.   matchread 20
  31.   ChrDelay 1
  32.   Write "+++"
  33.   ChrDelay 0
  34.   Pause 7
  35.   DtrClear
  36.   SBreak
  37.   DtrSet
  38.  
  39.   SerReset 19200,0,8,2
  40.   write "AT+VC=0\r"
  41.   matchclr
  42.   matchstr 1 1 "OK\r\n"
  43.   matchread 10
  44. !
  45.   DecTries
  46.   IfTries 0 1
  47.   exit -6019
  48.  
  49. @Label 2
  50.   SerReset 19200,0,8,1
  51.   Jsr 80
  52.   Write "AT+FCLASS=0\r"
  53.   Jsr 100
  54.   Write "AT+FAE=0\r"
  55.   Jsr 100
  56.   exit 0
  57.  
  58.  
  59. ! ------------------------------------------
  60. !    Receiving incoming calls
  61. ! ------------------------------------------
  62. @ANSWER
  63. !
  64. ! Set the modem preferred speed first
  65. !
  66.   SerReset 19200,0,8,1
  67.   Jsr 80
  68.   Jsr 70
  69.  
  70. @Label 3
  71.   ifOpen "Voice" 4
  72.   Jump 50
  73.  
  74. ! check to see if the voice code has been downloaded
  75. ! if not, tell PhonePro to download it.
  76. !
  77. @Label 4
  78.   Note "Checking the modem…"
  79.   Write "AT+VC=0\r"
  80.   MatchClr
  81.   MatchStr 1 5 "OK\r\n"
  82.   MatchStr 2 5 "ERROR\r\n"
  83.   MatchRead 10
  84.   Exit -6019
  85.  
  86. @Label 5
  87.   Write "AT+VC=1\r"
  88.   MatchClr
  89.   MatchStr 1 7 "OK\r\n"
  90.   MatchStr 2 6 "ERROR\r\n"
  91.   MatchRead 20
  92.   Exit -6019
  93. !
  94. !  tell the Voice Tool to download the voice code
  95. !
  96. @Label 6
  97.   Note "Downloading voice code to modem…"
  98.   Pause 20
  99.   QueueInput "\r\nLOAD\r\n"
  100.   Attach "Voice" (Master)
  101.  
  102. @Label 7
  103.   Write "AT+VC=0\r"
  104.   Jsr 100
  105. !
  106. ! sit and wait for a call for up two minutes, then re-initiate the modem
  107. !
  108. @Label 8
  109.   Note "Waiting for a Voice/Fax/ARA call"
  110.   MatchClr
  111.   MatchStr 1 15 "RING\r\n"
  112.   MatchRead 300
  113.   Jump 3
  114. !
  115. !
  116. !
  117. @Label 15
  118.   Note "Ring…"
  119.   QueueInput "\r\nRING\r\n"
  120.   Attach "Voice" (Master)
  121.   Write "+++"
  122.   Note "Switching from voice…"
  123.   Pause 5
  124. !
  125. ! fall through if the call is not a voice call (as indicated by the telephone tool)
  126. !
  127.   SetVar A "^$"
  128.   Write "ATV1+VC=0\r"
  129.   Jsr 100
  130.   SerReset 19200,0,8,1
  131.   HsReset 0,0,17,19,0,0
  132.   Jsr 80
  133.   Write "ATV1+VC=0\r"
  134.   Jsr 100
  135.   Write "AT&F\r"
  136.   Jsr 100
  137.   Jsr 70
  138.  
  139.   IfStr A 17 "Fax"
  140.   IfStr A 18 "ARA"
  141.   Exit -6019
  142.  
  143. !
  144. ! Force to answer a Fax call
  145. !
  146. @Label 17
  147.   Note "Switching to Fax…"
  148.   Write "AT+FCLASS=1;+FAE=0\r"
  149.   Jsr 100
  150.   Write "AT&K4V0A\r"
  151.   MatchClr
  152.   MatchStr 1 30 "1\r"
  153.   MatchStr 2 93 "3\r"
  154.   MatchStr 3 94 "8\r"
  155.   MatchRead 300
  156.   Write "\r"
  157.   Exit -6019
  158.  
  159. !
  160. ! Force to answer an ARA call
  161. !
  162. @Label 18
  163.   Note "Switching to ARA…"
  164. ! Set the communication options:
  165.   Jsr 55
  166.  
  167.   Write "AT+FAE=0;+FCLASS=0\r"
  168.   Jsr 100
  169.   Write "ATA\r"
  170.   MatchClr
  171.   MatchStr 1 20 "\r\nCARRIER "
  172.   MatchStr 4 93 "NO CARRIER\r\n"
  173.   MatchStr 5 94 "NO ANSWER\r\n"
  174.   MatchRead 300
  175.   Write "\r"
  176.   Exit -6019
  177.  
  178. @Label 20
  179.   QueueInput "\r\nCARRIER "
  180.   ifOriginate 21
  181.   QueueInput "\r\nRING\r\n"
  182. @Label 21
  183.   Attach "ARA" (DTR,Escape,TimeLimit=0)
  184.  
  185. !
  186. ! Fax connection has been established (we read "1\r")
  187. ! Attach the "Fax" subPort
  188. !
  189. @Label 30
  190.   QueueInput "1\r"
  191.   ifOriginate 32
  192. @Label 31
  193.   QueueInput "2\r"
  194. @Label 32
  195.   Attach "Fax" (Reset(2400),IdleLimit=30)
  196.  
  197. !
  198. ! Converting numeric responses into verbal
  199. !
  200. @Label 40
  201.   QueueInput "2400\r\n"
  202.   Jump 20
  203. @Label 41
  204.   QueueInput "4800\r\n"
  205.   Jump 20
  206. @Label 42
  207.   QueueInput "7200\r\n"
  208.   Jump 20
  209. @Label 43
  210.   QueueInput "9600\r\n"
  211.   Jump 20
  212. @Label 44
  213.   QueueInput "12000\r\n"
  214.   Jump 20
  215. @Label 45
  216.   QueueInput "14400\r\n"
  217.   Jump 20
  218.  
  219. !
  220. ! Waiting for Fax/ARA calls only (no Voice App running)
  221. !
  222. @Label 50
  223.   Note "Voice Application is not running…"
  224.   Jsr 55
  225. !
  226. ! Set Fax mode
  227. !
  228.   Write "AT+FCLASS=1\r"
  229.   Jsr 100
  230.   Write "AT+FAE=1\r"
  231.   Jsr 100
  232.   Write "AT+FCLASS=0\r"
  233.   Jsr 100
  234. !
  235. ! Tell the modem to determine the type of the incoming call
  236. ! Fetch the tube after ^4 rings
  237. !
  238.   Write "ATS0=^4V0\r"
  239.   Jsr 110
  240. !
  241. ! Everything is ready - let's sit and wait for a call
  242. ! We'll wait for 2 minutes, then reinitiate the modem
  243. !
  244.   Note "Waiting for a fax or ARA call…"
  245.   MatchClr
  246.   matchstr 02 40 "47\r"
  247.   MatchStr 03 41 "48\r"
  248.   MatchStr 04 42 "49\r"
  249.   MatchStr 05 43 "50\r"
  250.   MatchStr 06 44 "51\r"
  251.   MatchStr 07 45 "52\r"
  252.   MatchStr 09 31 "33\r"
  253.   matchstr 10 53 "2\r"
  254.   matchstr 12 30 "1\r"
  255.   matchstr 13 52 "3\r"
  256.   matchstr 14 52 "8\r"
  257.   matchstr 15 52 "7\r"
  258. @Label 51
  259.   Matchread 300
  260.   ifOpen "Voice" 52
  261.   Matchread 300
  262. @Label 52
  263.   Write "ATV1\r"
  264.   Jsr 100
  265.   Jump 3
  266. @Label 53
  267.   Note "Ring…"
  268.   Jump 51
  269.  
  270. ! ------------------------------------------
  271. ! Originating a call through the "Voice" subport
  272. ! ------------------------------------------
  273. @ORIGINATE "Voice"
  274.   Note "PhonePro is originating a call …"
  275.   Attach "Voice" (Escape, Master)
  276.   Exit -6019
  277.  
  278.  
  279.  
  280. ! ------------------------------------------
  281. ! Originating a call through the "ARA" subport
  282. ! ------------------------------------------
  283. @ORIGINATE "ARA"
  284.   SerReset 19200,0,8,1
  285.   Jsr 80
  286. !
  287. ! Set the common options
  288. !
  289.   Jsr 70
  290.   Jsr 55
  291. !
  292. ! Prepare to receive all error result codes, dial the number
  293. !
  294.   Jsr 90
  295.   MatchStr 1 20 "\r\nCARRIER "
  296.   MatchRead 1000
  297.   Write "\r"
  298.   Exit -6019
  299.  
  300. ! ------------------------------------------
  301. ! Originating a call through the "Fax" subPort
  302. ! ------------------------------------------
  303. @ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
  304. !
  305. ! Set the "Fax" speed
  306. !
  307.   SerReset 19200,0,8,1
  308.   Jsr 80
  309.   Write "ATZ\r"
  310.   Jsr 100
  311.  
  312.   Write "AT+VC=0\r"
  313.   Jsr 120
  314. !
  315. ! Set the common options
  316. !
  317.   Jsr 70
  318. !
  319. ! Set the Fax mode
  320. ! &K4: Xon/Xoff handshake
  321. !
  322.   Write "AT&K4+FCLASS=1\r"
  323.   Jsr 100
  324.   Write "AT+VC=0\r"
  325.   Jsr 120
  326. !
  327. ! Now emit all commands that the application has sent to that port,
  328. ! except "FCLASS", etc
  329. !
  330.   EmitClear "FCLASS","V","X","E","S0"
  331.   Jsr 60
  332.   Write "ATV0\r"
  333.   Jsr 110
  334. !
  335. ! Prepare to receive all error result codes, dial the number
  336. !
  337.   MatchClr
  338.   MatchStr 01 30 "1\r"
  339.   MatchStr 13 93 "3\r"
  340.   MatchStr 14 94 "8\r"
  341.   MatchStr 15 92 "7\r"
  342.   Write "ATD^1\r"
  343.   HsReset *
  344.   MatchRead 900
  345.   Write "\r"
  346.   Exit -6019
  347.  
  348. !
  349. ! Set the communication options:
  350. ! • \N0 &Q6: Normal connection (for ARA)
  351. ! • &K3: HW flow control       (for ARA, Fax should not use a handshake on receiving)
  352. ! • W1:  report connection speed
  353. !
  354. @Label 55
  355.   Write "AT\\N0&Q6&K3W1\r"
  356.   Jsr 100
  357.   return
  358.  
  359. !
  360. ! This section emits all modem commands sent from the client application
  361. ! For each set of commands the "OK" answer is awaited
  362. !
  363. @Label 60
  364.   EmitStart
  365. @Label 61
  366.   EmitCommand 62
  367.   Jsr 100
  368.   Jump 61
  369. @Label 62
  370.   return
  371. !
  372. ! This section initiates the modem before ANSWER and ORIGINATEs:
  373. ! extended responses + connect at the highest rate + speaker control +
  374. ! reset on Dtr drop + DCD valid
  375. ! Verbal responses mode, no echo 
  376. !
  377. @Label 70
  378.   Write "ATX4N1M^2L^3^6&C1V1E0\r"
  379.   Jsr 100
  380.   return 
  381.  
  382. !
  383. ! This section syncronize the modem after the serial port speed switching
  384. !
  385. @Label 80
  386.   ChrDelay 1
  387.   Write "AT\r"
  388.   ChrDelay 0
  389.   Jsr 100
  390.   return
  391. !
  392. ! Prepare to receive error result codes, send the dialing command and
  393. ! set the user's handshake mode
  394. !
  395. @Label 90
  396.   MatchClr
  397.   MatchStr 2 91 "NO DIALTONE\r\n"
  398.   MatchStr 3 92 "BUSY\r\n"
  399.   MatchStr 4 93 "NO CARRIER\r\n"
  400.   MatchStr 5 94 "NO ANSWER\r\n"
  401.   Write "ATD^1\r"
  402.   HsReset *
  403.   return
  404.  
  405. @Label 91
  406.   exit -6020
  407. @Label 92
  408.   exit -6022
  409. @Label 93
  410.   exit -6021
  411. @Label 94
  412.   exit -6023
  413. !
  414. ! Processing the AT command:
  415. ! OK -> proceed
  416. ! ERROR or TimeOut ->exit -6019
  417. ! It can be called AFTER the "Write" command, since LineShare buffers input
  418. !
  419. @Label 100
  420.   MatchClr
  421.   MatchStr 1 103 "\r\nOK\r\n"
  422.   MatchStr 2 102 "\r\nERROR\r\n"
  423. @Label 101
  424.   MatchRead 20
  425. @Label 102
  426.   Exit -6019
  427. @Label 103
  428.   return
  429.  
  430. @Label 110
  431.   MatchClr
  432.   MatchStr 1 103 "0\r"
  433.   MatchStr 2 102 "4\r"
  434.   Jump 101
  435.  
  436. @Label 120
  437.   MatchClr
  438.   MatchStr 1 103 "\r\nOK\r\n"
  439.   MatchStr 2 103 "\r\nERROR\r\n"
  440.   MatchRead 20
  441.   Exit -6019
  442.  
  443.